package com.dkakunsi.monev.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dkakunsi.monev.dao.LoginDao;
import com.dkakunsi.monev.entity.User;
import com.dkakunsi.monev.util.MonevDataException;

@Service("loginService")
@Transactional(readOnly=true)
public class LoginService {
	@Autowired private LoginDao dao;
	
	@Transactional(readOnly=false)
	public void tambahUser(User user) {
		dao.save(user);
	}
	
	@Transactional(readOnly=false)
	public void hapusUser(User user) {
		dao.delete(user);
	}
	
	public User getUser(String username) throws MonevDataException {
		return dao.get(username);
	}
	
	public List<User> getAll() throws MonevDataException {
		return dao.getAll();
	}
}
